import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)


import MainSection from '@/pages/MainSection.vue'
/**/import Insert from '@/components/Insert.vue'
/**/import Region from '@/components/Region.vue'
/**/import User from '@/components/User.vue'
/**/import FilmList from '@/components/FilmList.vue'
/**/import Password from '@/components/Password.vue'

import NotFound from '@/pages/404.vue'

//src/config/leftmenu.js控制左侧菜单显示

const routes = [
    
    { path: '/', redirect: '/admin' },
    { name:'admin',path: '/admin', component:() => import(/* webpackChunkName: "AdminLogin" */ '@/pages/AdminLogin.vue')},
    { name:'register',path: '/register', component: () => import(/* webpackChunkName: "Register" */ '@/pages/Register.vue') },
    { name:'name',path: '/adm', component: MainSection,
        children: [
            { path: '/', redirect: 'insertfilm' },
            { name: "insertfilm", path: 'insertfilm', component: Insert },
            { name:'qualification',path: 'qualification', component: () => import(/* webpackChunkName: "Qualification" */ '@/pages/Qualification.vue') },
            { name:'marketregion',path: 'marketregion', component: () => import(/* webpackChunkName: "Marketregion" */ '@/pages/Marketregion.vue') },
            { name:"region",path: 'region', component: Region },
            {
                name:'articallist',
                path:'articallist',
                component: () => import(/* webpackChunkName: "ArticalList" */ '@/components/ArticalList.vue'),
                meta: { requireAuth: true },
                //上面是main.js里全局控制
                beforeEnter: (to, from, next) => {
                    console.log('artical内部守卫')
                    next()
                }
            },
            {name:"user",path: 'user', component: User },
            {name:"filmlist",path: 'filmlist', component: FilmList },
            {name:"password",path: 'password', component: Password },
            {name:"userlist",path: 'userlist', component: () => import(/* webpackChunkName: "UserList" */ '@/components/UserList.vue') },
        ]
    }
    


    //*代表所有错误页面,可以用redirect配合path的值,也可以component配合组件的值.
]


const router = new VueRouter({
    routes // short for `routes: routes`
})
router.addRoutes([{ path: "*", component: NotFound }]);
export default router